package experiment;

/**
 * @Author:云尚
 * @Description:请用递归计算出1-100的和
 */
public class Demo6 {
    public static int sum(int i){
        if(i==1){
            return 1;//i等于1的返回1，下面累加终止，开始返回累加
        }
        return sum(i-1)+i;
    }

    public static void main(String[] args) {
        int result= sum(100);
        System.out.println(result);
    }
}


